package com.oms.servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.liudecai.utils.common.CommonUtils;
import com.oms.bean.RequestBean;
import com.oms.dao.Request2BeanDao;

@WebServlet("/Request2Bean")
public class Request2Bean extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public Request2Bean() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		RequestBean bean = CommonUtils.MyReqest2Bean(request, response, RequestBean.class);
		System.out.println(bean);
		Request2BeanDao dao = new Request2BeanDao();
		try {
			dao.Add(bean);
		} catch (SQLException e) {
			System.out.println("添加数据出错!");
			e.printStackTrace();
		}
		response.getWriter().append("Served at: ").append(request.getContextPath());
		response.getWriter().write("  username="+bean.getUsername()+"  password="+bean.getPassword()+"  telephone="+bean.getTelephone());
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
